package com.yanqu.road.server.cmd.monopolymarket;

import com.yanqu.road.pb.monopolymarket.MonopolyMarketProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.monopolymarket.MonopolyMarketModule;
import com.yanqu.road.server.manger.monopolymarket.MonopolyMarketMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2021/8/11 16:32
 */
@Cmd(code = GameProtocol.S_MONOPOLY_MARKET_EXIT, desc = "玩家离线 和离开榷署座位")
public class MonopolyMarketExitSeatCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        MonopolyMarketProto.MonopolyMarketExitReqMsg req = MonopolyMarketProto.MonopolyMarketExitReqMsg.parseFrom(packet.getBytes());
        MonopolyMarketModule marketModule = player.getModule(MonopolyMarketModule.class);
        if(req.getIsExitMonopolyMarket()){
            marketModule.inSystemId = -1;
        }
        if(req.getIsExitOffice() || req.getIsExitResGrabKing() || req.getIsExitResGrabQueen()){
            marketModule.inSystemId = 0;
        }
        MonopolyMarketMgr.exit(player,req.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
    }

}
